package deposit.tests;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.junit.Assert;
import org.junit.Test;

import deposit.main.MonthCapitalizeDeposit;

public class MonthCapitalizeDepositTest {

    @Test
    public void getInterestTest1() {
	MonthCapitalizeDeposit mcd = new MonthCapitalizeDeposit();
	mcd.setStartDate(new GregorianCalendar(2012, Calendar.SEPTEMBER, 8)
		.getTime());
	mcd.setDayLong(80);
	mcd.setSum(1000.0);
	mcd.setInterestRate(15.0);

	double expectedInterest = 33.23;
	double actualInterest = mcd.getInterest();
	//actualInterest = Math.round(actualInterest * 100.0) / 100.0;
	Assert.assertEquals(expectedInterest, actualInterest, 0.005);
    }

    @Test
    public void getInterestTest2() {
	MonthCapitalizeDeposit mcd = new MonthCapitalizeDeposit();
	mcd.setStartDate(new GregorianCalendar(2012, Calendar.SEPTEMBER, 8)
		.getTime());
	mcd.setDayLong(20);
	mcd.setSum(1000.00);
	mcd.setInterestRate(15.0);
	
	double expectedInterest = 8.22;
	double actualInterest = mcd.getInterest();
	Assert.assertEquals(expectedInterest, actualInterest, 0.005);
    }

    @Test
    public void getInterestTest3() {
	MonthCapitalizeDeposit mcd = new MonthCapitalizeDeposit();
	mcd.setStartDate(new GregorianCalendar(2012, Calendar.SEPTEMBER, 8)
		.getTime());
	mcd.setDayLong(30);
	mcd.setSum(1000.00);
	mcd.setInterestRate(15.0);
	
	double expectedInterest = 12.36;
	double actualInterest = mcd.getInterest();
	Assert.assertEquals(expectedInterest, actualInterest, 0.005);
    }

    @Test
    public void getInterestTest4() {
	MonthCapitalizeDeposit mcd = new MonthCapitalizeDeposit();
	mcd.setStartDate(new GregorianCalendar(2012, Calendar.MAY, 12)
		.getTime());
	mcd.setDayLong(180);
	mcd.setSum(1000.00);
	mcd.setInterestRate(15.0);
	
	double expectedInterest = 76.32;
	double actualInterest = mcd.getInterest();
	Assert.assertEquals(expectedInterest, actualInterest, 0.005);
    }
}
